//
//  NewsCell.m
//  Project1
//
//  Created by 黄珂耀 on 15/7/20.
//  Copyright (c) 2015年 黄珂耀. All rights reserved.
//

#import "NewsCell.h"
#import "UIImageView+WebCache.h"

@implementation NewsCell

- (void)awakeFromNib {
    // Initialization code
    
    self.selectionStyle = UITableViewCellSelectionStyleDefault;
    
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}


- (void)setModal:(NewsModal *)modal
{
    _modal = modal;
    [self setNeedsLayout];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_main"]];
    
    _titleLabel.text = _modal.title;
    
    int index = [_modal.type intValue];
    
    if (index == 1)
    {
        _typeImage.hidden = NO;
    }
    else
    {
        _typeImage.hidden = YES;
    }
    
    _summaryLabel.text = _modal.summary;
    
    NSString *imageURl = _modal.image;
    [_newsImageView sd_setImageWithURL:[NSURL URLWithString:imageURl]];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
